import Vue from 'vue'
import VueRouter from 'vue-router'
import layout from '../views/layout/IndexView.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/home'
  },
  {
    path: '/home',
    // name: 'layout',
    component: layout,

    redirect: '/home/dashboard'
    ,
    meta: { title: '首页', icon: 'icon-panel' },
    children: [

      {
        path: 'dashboard',
        name: 'dashboard',
        meta: { title: '仪表盘' },
        component: () => import(/* webpackChunkName: "dashboard" */ '../views/dashboard/IndexView.vue')
      },
      {
        path: 'data',
        name: 'data',
        meta: { title: '设备数据' },
        component: () => import(/* webpackChunkName: "data" */ '../views/dashboard/DataView.vue')
      }
    ]
  },
  {
    path: '/login',
    name: 'login',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "login" */ '../views/login/IndexView.vue')
  },

  {
    path: '/device',
    name: 'device',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: layout,
    redirect: '/device/group',
    meta: { title: '设备', icon: 'icon-luyouqi' },
    children: [


      {
        path: 'group',
        name: 'group',
        meta: { title: '网关' },

        component: () => import(/* webpackChunkName: "getway" */ '../views/shebei/DeviceGroup.vue')
      },
      {
        path: 'gateway',
        name: 'gateway',
        meta: { title: '设备群组' },
        component: () => import(/* webpackChunkName: "getway" */ '../views/shebei/GateWay.vue')
      },
      {
        path: 'list',
        name: 'list',
        meta: { title: '传感器列表' },
        component: () => import(/* webpackChunkName: "list" */ '../views/shebei/SensorList.vue')
      }
    ]
  },
  {
    path: '/charg',
    // name: 'charg',
    component: layout,

    redirect: '/charg/account',

    meta: { title: '计费', icon: 'icon-fyxx' },

    children: [

      {
        path: 'account',
        name: 'account',
        meta: { title: '账户信息' },
        component: () => import(/* webpackChunkName: "account" */ '../views/charg/AccountV.vue')
      },
      {
        path: 'recharge',
        name: 'recharge',
        meta: { title: '充值记录' },
        component: () => import(/* webpackChunkName: "recharge" */ '../views/charg//ReCharge.vue')
      },
      {
        path: 'useage',
        name: 'useage',
        meta: { title: '使用记录' },
        component: () => import(/* webpackChunkName: "useage" */ '../views/charg//UseAge.vue')
      }
    ]
  },

  {
    path: '/securi',
    // name: 'charg',
    component: layout,

    redirect: '/securi/security',
    meta: { title: '安全', icon: 'icon-anquan' },
    children: [

      {
        path: 'security',
        name: 'security',
        meta: { title: '添加秘钥' },
        component: () => import(/* webpackChunkName: "security" */ '../views/security/SecuriTy.vue')
      },
      {
        path: 'seclist',
        name: 'seclist',
        meta: { title: '秘钥列表' },
        component: () => import(/* webpackChunkName: "SecList" */ '../views/security/SecList.vue')
      }
    ]
  },
  {
    path: '/*',
    name: 'page404View"',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "page404" */ '../views/pageP404/IndexView.vue')
  }
]

const router = new VueRouter({
  routes
})

export default router
